package com.yue.util;

import javax.servlet.http.Part;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/11/30<br/>
 *
 * @author QiuYang
 */
public class FileLoadUtil {

    public static String getFileType(Part part){
        String name = part.getHeader("content-disposition");
        System.out.println("name : " + name);
        String fileNameTmp = name.substring(name.indexOf("filename=")+10);
        System.out.println("fileNameTmp : " + fileNameTmp);
        String type = fileNameTmp.substring(fileNameTmp.indexOf(".")+1, fileNameTmp.indexOf("\""));
        return type;
    }

    public static String getFileName(Part p){
        String name = p.getHeader("content-disposition");
        String fileNameTmp = name.substring(name.indexOf("filename=")+10);
        String fileName = fileNameTmp.substring(0, fileNameTmp.indexOf("\""));
        return fileName;

    }
}
